home *** CD-ROM | disk | FTP | other *** search
/ The World of Computer Software / The World of Computer Software.iso / pcl4c341.zip / PCL4C.REF < prev    next >
Text File  |  1993-01-01  |  61KB  |  2,283 lines

  1.  
  2.  
  3.                           Personal Communications Library
  4.  
  5.                                 For the C Language
  6.  
  7.  
  8.                                     (PCL4C)
  9.  
  10.  
  11.  
  12.                                REFERENCE MANUAL
  13.  
  14.  
  15.  
  16.  
  17.  
  18.                                   Version  3.4
  19.  
  20.                                   Jan 4,  1993
  21.  
  22.  
  23.  
  24.  
  25.                         This software is provided as-is.
  26.                  There are no warranties, expressed or implied.
  27.  
  28.  
  29.  
  30.  
  31.                               Copyright (C) 1993
  32.                               All rights reserved
  33.  
  34.  
  35.  
  36.                               MarshallSoft Computing, Inc.
  37.                               Post Office Box 4543
  38.                               Huntsville AL 35815
  39.  
  40.                               Voice 205-881-4630
  41.                               FAX   205-881-4630
  42.                               BBS   205-880-9748
  43.  
  44.  
  45.  
  46.  
  47.  
  48.  
  49.  
  50.  
  51.  
  52.  
  53.  
  54.  
  55.  
  56.  
  57.  
  58.  
  59.  
  60.         PCL4C Reference Manual                                 Page 1
  61.                                C O N T E N T S
  62.  
  63.  
  64.  
  65.               Chapter                                     Page
  66.  
  67.               Table of Contents.............................2
  68.               Introduction..................................3
  69.                  SioBaud....................................4
  70.                  SioBrkKey..................................5
  71.                  SioBrkSig..................................6
  72.                  SioCrtWrite................................7
  73.                  SioCTS.....................................8
  74.                  SioDCD.....................................9
  75.                  SioDelay..................................10
  76.                  SioDone...................................11
  77.                  SioDSR....................................12
  78.                  SioDTR....................................13
  79.                  SioError..................................14
  80.                  SioFIFO...................................15
  81.                  SioFlow...................................16
  82.                  SioGetc...................................17
  83.                  SioKeyPress...............................18
  84.                  SioKeyRead................................19
  85.                  SioInfo...................................20
  86.                  SioIRQ....................................21
  87.                  SioLine...................................22
  88.                  SioLoopBack...............................23
  89.                  SioModem..................................24
  90.                  SioParms..................................25
  91.                  SioPutc...................................26
  92.                  SioRead...................................27
  93.                  SioReset..................................28
  94.                  SioRI.....................................29
  95.                  SioRTS....................................30
  96.                  SioRxBuf..................................31
  97.                  SioRxFlush................................32
  98.                  SioRxQue..................................33
  99.                  SioTimer..................................34
  100.                  SioUART...................................35
  101.                  SioUnGetc.................................36
  102.               Function Summary.............................37
  103.               Error Code Summary...........................38
  104.  
  105.  
  106.  
  107.  
  108.  
  109.  
  110.  
  111.  
  112.  
  113.  
  114.  
  115.  
  116.  
  117.  
  118.  
  119.  
  120.         PCL4C Reference Manual                                 Page 2
  121.                                   Introduction
  122.  
  123.  
  124.  
  125.          This manual lists all of the PCL4C functions in alphabetical
  126.          order. Every library function will return a value as follows:
  127.  
  128.          1.  Negative values for error conditions. See last page of this
  129.          manual for a list of error values and their meanings.
  130.  
  131.          2.  Non-negative values when returning data (eg: SioLine).
  132.  
  133.          3.  Zero otherwise.
  134.  
  135.          When debugging an application, be sure to test all return values.
  136.          Use SioError to print the associated text for errors.
  137.  
  138.          Example Code Segment
  139.  
  140.  
  141.          *****************************************************************
  142.          * int Code;                 /* MUST be 'int', not 'char' */     *
  143.          *                                                               *
  144.          * Code = SioFunction( );    /* any PCL4C function */            *
  145.          * if(Code<0)                                                    *
  146.          *   {/* error returned */                                       *
  147.          *    SioError(Code);        /* SioError prints error text */    *
  148.          *    SioDone(Port);         /* always call SioDone last */      *
  149.          *    exit(1);                                                   *
  150.          *   }                                                           *
  151.          * /* no errors */                                               *
  152.          * ...your application code...                                   *
  153.          *                                                               *
  154.          *****************************************************************
  155.  
  156.  
  157.          For  more  examples, examine each of the example programs provided
  158.          (SIMPLE.C and TERM.C). Also look at the examples  associated  with
  159.          each library function described in the following section.
  160.  
  161.          Refer to the User's Manual (PCL4C.USR) for addition information.
  162.  
  163.  
  164.  
  165.  
  166.  
  167.  
  168.  
  169.  
  170.  
  171.  
  172.  
  173.  
  174.  
  175.  
  176.  
  177.  
  178.  
  179.  
  180.         PCL4C Reference Manual                                 Page 3
  181.                                   SioBaud
  182.  
  183.  
  184.  
  185.          Function    Sets the baud rate of the selected port.
  186.  
  187.            Syntax    int SioBaud(Port,BaudCode)
  188.                      int Port;     /* Port selected (COM1 - COM4) */
  189.                      int BaudCode; /* Baud code */
  190.  
  191.  
  192.           Remarks    The  SioBaud  function  sets  the  baud  rate  without
  193.                      resetting the port. It is used to change the baud rate
  194.                      after calling SioReset.
  195.  
  196.                      Baud Code           Baud Rate       PCL4C.H Name
  197.                           0                 300            Baud300
  198.                           1                 600            Baud600
  199.                           2                1200            Baud1200
  200.                           3                2400            Baud2400
  201.                           4                4800            Baud4800
  202.                           5                9600            Baud9600
  203.                           6               19200            Baud19200
  204.                           7               38400            Baud38400
  205.                           8               57600            Baud57600
  206.                           9              115200            Baud115200
  207.  
  208.  
  209.           Returns     -4 : Port out of range. Expected   0  to 3.
  210.                      -11 : Bad baud rate code. See above code values.
  211.  
  212.           Example    /* do auto baud detect */
  213.                      for(Code=0;Code<10;Code++)
  214.                        {/* set baud rate & transmit 'A' */
  215.                         SioBaud(Port,Code);
  216.                         SioPutc(Port,'A');
  217.                         /* assume other side echos back */
  218.                         if(SioGetc(Port,18)=='A'))
  219.                           {puts("Baud rate detected");
  220.                            /*...do something here...*/
  221.                           }
  222.                         }
  223.  
  224.          See Also    SioReset
  225.  
  226.  
  227.  
  228.  
  229.  
  230.  
  231.  
  232.  
  233.  
  234.  
  235.  
  236.  
  237.  
  238.  
  239.  
  240.         PCL4C Reference Manual                                 Page 4
  241.                                   SioBrkKey
  242.  
  243.  
  244.  
  245.          Function    Return non-zero if the Control-BREAK key was pressed.
  246.  
  247.            Syntax    int SioBrkKey()
  248.  
  249.           Remarks    The SioBrkKey function  returns  a  TRUE  value  (non-
  250.                      zero)  if  the  Control-BREAK key was pressed, else it
  251.                      returns a zero. Use SioBrkKey as a safety exit from  a
  252.                      polling   loop.   Don't  mix  this  function  up  with
  253.                      SioBrkSig.
  254.  
  255.           Returns    -1 : Control-BREAK was pressed.
  256.                       0 : Control-BREAK was NOT pressed.
  257.  
  258.           Example    int c;
  259.                      ...
  260.                      while(1)
  261.                        {/* exit if user pressed Control-BREAK */
  262.                         if(SioBrkKey())
  263.                           {puts("User typed Contrl-BREAK");
  264.                            SioDone(Port);
  265.                            exit(1);
  266.                           }
  267.                         /* transmit any typed character */
  268.                         if(SioKeyPress())
  269.                           {c = SioKeyRead();
  270.                            SioPutc(Port,c);
  271.                           }
  272.                         /* display any incoming character */
  273.                         c = SioGetc(Port,0);
  274.                         if(c!=-1)  SioCrtWrite(c);
  275.                        }
  276.  
  277.          See Also    SioBrkSig
  278.  
  279.  
  280.  
  281.  
  282.  
  283.  
  284.  
  285.  
  286.  
  287.  
  288.  
  289.  
  290.  
  291.  
  292.  
  293.  
  294.  
  295.  
  296.  
  297.  
  298.  
  299.  
  300.         PCL4C Reference Manual                                 Page 5
  301.                                   SioBrkSig
  302.  
  303.  
  304.  
  305.          Function    Asserts, cancels, or detects BREAK signal.
  306.  
  307.            Syntax    int SioBrkSig(Port,Cmd)
  308.                      int Port;      /* Port selected (COM1 thru COM4) */
  309.                      char Cmd;      /* ASSERT, CANCEL, or DETECT */
  310.  
  311.           Remarks    The SioBrkSig function controls the BREAK bit  in  the
  312.                      line status register. The legal commands are:
  313.  
  314.                      ASSERT_BREAK ('A') to assert BREAK
  315.                      CANCEL_BREAK ('C') to cancel BREAK
  316.                      DETECT_BREAK ('D') to detect BREAK
  317.  
  318.                      ASSERT_BREAK,   CANCEL_BREAK,   and  DETECT_BREAK  are
  319.                      defined in PCL4C.H. See TERM.C for an example  of  the
  320.                      use of SioBrkSig.
  321.  
  322.           Returns    -2 : Port not enabled. Call SioReset first.
  323.                      -4 : Port out of range. Expected  0 to 3.
  324.                      -6 : Illegal command. Expected 'A', 'C', or 'D'.
  325.                      >0 : BREAK signal detected (DETECT command only)
  326.  
  327.           Example    /* Assert BREAK for 1 second */
  328.                      SioBrkSig(Port,ASSERT_BREAK);
  329.                      SioDelay(18);
  330.                      SioBrkSig(Port,CANCEL_BREAK);
  331.                      /* Detect BREAK */
  332.                      if(SioBrkSig(Port,DETECT_BREAK))
  333.                        {puts("BREAK signal detected");
  334.                         /* ...do some more stuff... */
  335.                        }
  336.  
  337.          See Also    SioBrkKey
  338.  
  339.  
  340.  
  341.  
  342.  
  343.  
  344.  
  345.  
  346.  
  347.  
  348.  
  349.  
  350.  
  351.  
  352.  
  353.  
  354.  
  355.  
  356.  
  357.  
  358.  
  359.  
  360.         PCL4C Reference Manual                                 Page 6
  361.                                   SioCrtWrite
  362.  
  363.  
  364.  
  365.          Function    Write character to the screen.
  366.  
  367.            Syntax    int SioCrtWrite(ch)
  368.                      char ch;        /* character to write */
  369.  
  370.           Remarks    The  SioCrtWrite  function  uses  the  BIOS to write a
  371.                      single character to the screen at the  current  cursor
  372.                      location.
  373.  
  374.                      SioCrtWrite   calls  the  BIOS  directly  without  any
  375.                      intermediate buffering or processing.  It  is  usually
  376.                      faster than a call to the C library.
  377.  
  378.           Returns    zero
  379.  
  380.           Example    /* wait up to 1 second (18 tics) for character */
  381.                      if( (c = SioGetc(COM1,18)) != -1)
  382.                        {/* echo to screen */
  383.                         SioCrtWrite(c);
  384.                        }
  385.  
  386.          See Also    SioKeyPress and SioKeyRead
  387.  
  388.  
  389.  
  390.  
  391.  
  392.  
  393.  
  394.  
  395.  
  396.  
  397.  
  398.  
  399.  
  400.  
  401.  
  402.  
  403.  
  404.  
  405.  
  406.  
  407.  
  408.  
  409.  
  410.  
  411.  
  412.  
  413.  
  414.  
  415.  
  416.  
  417.  
  418.  
  419.  
  420.         PCL4C Reference Manual                                 Page 7
  421.                                   SioCTS
  422.  
  423.  
  424.  
  425.          Function    Reads the Clear to Send (CTS) modem status bit.
  426.  
  427.            Syntax    int SioCTS(Port)
  428.                      int Port;   /* Port selected (COM1 thru COM4) */
  429.  
  430.           Remarks    The  SioCTS function is used to read the Clear to Send
  431.                      (CTS) modem status bit.
  432.  
  433.                      The  CTS  line is used by some error correcting modems
  434.                      to implement hardware flow control.  CTS is dropped by
  435.                      the modem to signal the computer not to send data, and
  436.                      is raised to signal the computer to continue.
  437.  
  438.                      Refer to the User's Manual for a  discussion  of  flow
  439.                      control.
  440.  
  441.           Returns    -2 : Port not enabled. Call SioReset first.
  442.                      -4 : Port out of range.  Expected  0 to 3.
  443.                       0 : CTS is clear.
  444.                      >0 : CTS is set.
  445.  
  446.           Example   /* wait for CTS to go active */
  447.                      while(1)
  448.                        {if(SioCTS(Port)) break;
  449.                         if(SioBrkKey())
  450.                            {puts("Aborted by user");
  451.                             SioDone(Port);
  452.                             exit(1);
  453.                            }
  454.                        }
  455.                      /* now we can send the character */
  456.                      SioPutc(Port,ch);
  457.  
  458.          See Also    SioFlow, SioDSR, SioRI, SioDCD, and SioModem.
  459.  
  460.  
  461.  
  462.  
  463.  
  464.  
  465.  
  466.  
  467.  
  468.  
  469.  
  470.  
  471.  
  472.  
  473.  
  474.  
  475.  
  476.  
  477.  
  478.  
  479.  
  480.         PCL4C Reference Manual                                 Page 8
  481.                                   SioDCD
  482.  
  483.  
  484.  
  485.          Function    Reads the Data Carrier Detect (DCD) modem status bit.
  486.  
  487.            Syntax    int SioDCD(Port)
  488.                      int Port;      /* Port selected (COM1 thru COM4) */
  489.  
  490.           Remarks    The  SioDCD function is used to read the  Data Carrier
  491.                      Detect (DCD) modem status bit. Also see SioModem.
  492.  
  493.           Returns    -2 : Port not enabled. Call SioReset first.
  494.                      -4 : Port out of range.  Expected  0 to 3.
  495.                       0 : DCD is clear.
  496.                      >0 : DCD is set.
  497.  
  498.           Example    /* test data carrier status bit */
  499.                      if(SioDCD(Port))
  500.                      puts("Carrier is on");
  501.                      else puts("Carrier is off");
  502.  
  503.          See Also    SioDSR, SioCTS, SioRI, and SioModem.
  504.  
  505.  
  506.  
  507.  
  508.  
  509.  
  510.  
  511.  
  512.  
  513.  
  514.  
  515.  
  516.  
  517.  
  518.  
  519.  
  520.  
  521.  
  522.  
  523.  
  524.  
  525.  
  526.  
  527.  
  528.  
  529.  
  530.  
  531.  
  532.  
  533.  
  534.  
  535.  
  536.  
  537.  
  538.  
  539.  
  540.         PCL4C Reference Manual                                 Page 9
  541.                                   SioDelay
  542.  
  543.  
  544.  
  545.          Function    Delays one or more tics.
  546.  
  547.            Syntax    int SioDelay(tics)
  548.                      int tics;       /* # tics */
  549.  
  550.           Remarks    The SioDelay function is used to  delay  one  or  more
  551.                      timer  tics,  where each timer tic is approximately 55
  552.                      milliseconds (18 tics to the second).
  553.  
  554.           Returns    zero
  555.  
  556.           Example    /* delay 5 seconds */
  557.                      SioDelay(5*18);
  558.  
  559.          See Also    SioTimer
  560.  
  561.  
  562.  
  563.  
  564.  
  565.  
  566.  
  567.  
  568.  
  569.  
  570.  
  571.  
  572.  
  573.  
  574.  
  575.  
  576.  
  577.  
  578.  
  579.  
  580.  
  581.  
  582.  
  583.  
  584.  
  585.  
  586.  
  587.  
  588.  
  589.  
  590.  
  591.  
  592.  
  593.  
  594.  
  595.  
  596.  
  597.  
  598.  
  599.  
  600.         PCL4C Reference Manual                                 Page 10
  601.                                   SioDone
  602.  
  603.  
  604.  
  605.          Function    Terminates further serial processing.
  606.  
  607.            Syntax    int SioDone(Port)
  608.                      int Port;     /* Port selected (COM1 thru COM4) */
  609.  
  610.           Remarks    The   SioDone   function   terminates  further  serial
  611.                      processing. SioDone MUST be called before exiting your
  612.                      application so that  interrupts  can  be  restored  to
  613.                      their  original  state.   Failure to do this can crash
  614.                      the operating system.  If you forget to  call  SioDone
  615.                      before exiting, be sure to re-boot your computer.  You
  616.                      can call SioDone even if SioReset has not been called,
  617.                      so  it  is good practice to always call SioDone before
  618.                      exiting your application.
  619.  
  620.           Returns    -2 : Port not enabled. Call SioReset first.
  621.                      -4 : Port out of range. Expected  0 to 3.
  622.  
  623.           Example    /* terminate processing for COM3 */
  624.                      SioDone(COM3);
  625.  
  626.          See Also    SioReset.
  627.  
  628.  
  629.  
  630.  
  631.  
  632.  
  633.  
  634.  
  635.  
  636.  
  637.  
  638.  
  639.  
  640.  
  641.  
  642.  
  643.  
  644.  
  645.  
  646.  
  647.  
  648.  
  649.  
  650.  
  651.  
  652.  
  653.  
  654.  
  655.  
  656.  
  657.  
  658.  
  659.  
  660.         PCL4C Reference Manual                                 Page 11
  661.                                   SioDSR
  662.  
  663.  
  664.  
  665.          Function    Reads the Data Set Ready (DSR) modem status bit.
  666.  
  667.            Syntax    int SioDSR(Port)
  668.                      int Port;     /* Port selected (COM1 thru COM4) */
  669.  
  670.           Remarks    The SioDSR function is used to read the Data Set Ready
  671.                      (DSR) modem status bit.
  672.  
  673.           Returns    -2 : Port not enabled. Call SioReset first.
  674.                      -4 : Port out of range.  Expected  0 to 3.
  675.                       0 : DSR is clear.
  676.                      >0 : DSR is set
  677.  
  678.           Example    /* read DSR status bit */
  679.                      if(SioDSR(Port))
  680.                      puts("Modem is ready");
  681.                      else puts("Modem is not ready");
  682.  
  683.          See Also    SioCTS, SioRI, SioDCD, and SioModem
  684.  
  685.  
  686.  
  687.  
  688.  
  689.  
  690.  
  691.  
  692.  
  693.  
  694.  
  695.  
  696.  
  697.  
  698.  
  699.  
  700.  
  701.  
  702.  
  703.  
  704.  
  705.  
  706.  
  707.  
  708.  
  709.  
  710.  
  711.  
  712.  
  713.  
  714.  
  715.  
  716.  
  717.  
  718.  
  719.  
  720.         PCL4C Reference Manual                                 Page 12
  721.                                   SioDTR
  722.  
  723.  
  724.  
  725.          Function    Set, clear, or read the Data Terminal Ready (DTR) bit.
  726.  
  727.            Syntax    int SioDTR(Port,Cmd)
  728.                      int Port;     /* Port selected (COM1 thru COM4) */
  729.                      char Cmd;     /* DTR command (SET, CLEAR, or READ) */
  730.  
  731.           Remarks    The  SioDTR  function controls the Data Terminal Ready
  732.                      (DTR) bit in the  modem  control  register.   Commands
  733.                      (defined in PCL4C.H) are:
  734.  
  735.                      SET_LINE ('S')  to set DTR (ON)
  736.                      CLEAR_LINE ('C')  to clear DTR (OFF)
  737.                      READ_LINE ('R')  to read DTR
  738.  
  739.           Returns    -2 : Port not enabled. Call SioReset first.
  740.                      -4 : Port out of range. Expected  0 to 3.
  741.                      -5 : Not one of 'S', 'C', or 'R'.
  742.                       0 : DTR is OFF (READ_LINE Command).
  743.                      >0 : DTR is ON (READ_LINE Command).
  744.  
  745.           Example    /* turn DTR on for modem connected to COM4 */
  746.                      SioDTR(COM4,SET);
  747.  
  748.          See Also    SioRTS.
  749.  
  750.  
  751.  
  752.  
  753.  
  754.  
  755.  
  756.  
  757.  
  758.  
  759.  
  760.  
  761.  
  762.  
  763.  
  764.  
  765.  
  766.  
  767.  
  768.  
  769.  
  770.  
  771.  
  772.  
  773.  
  774.  
  775.  
  776.  
  777.  
  778.  
  779.  
  780.         PCL4C Reference Manual                                 Page 13
  781.                                   SioError
  782.  
  783.  
  784.  
  785.          Function    Displays error in text.
  786.  
  787.            Syntax    int SioError(Code)
  788.                      int Code; /* Error code returned from */
  789.                                /* a PCL4C function */
  790.  
  791.           Remarks    The  SioError  function  displays  the  error  in text
  792.                      corresponding to the error code.   During  development
  793.                      of  a communications application, it is a good idea to
  794.                      always  test  return  codes,  and  print   out   their
  795.                      descriptions with SioError.
  796.  
  797.           Returns    zero
  798.  
  799.           Example    code = SioReset(Port,Baud4800);
  800.                      /* display error message if error occurred */
  801.                      if(code<0) SioError(code);
  802.  
  803.  
  804.  
  805.  
  806.  
  807.  
  808.  
  809.  
  810.  
  811.  
  812.  
  813.  
  814.  
  815.  
  816.  
  817.  
  818.  
  819.  
  820.  
  821.  
  822.  
  823.  
  824.  
  825.  
  826.  
  827.  
  828.  
  829.  
  830.  
  831.  
  832.  
  833.  
  834.  
  835.  
  836.  
  837.  
  838.  
  839.  
  840.         PCL4C Reference Manual                                 Page 14
  841.                                   SioFIFO
  842.  
  843.  
  844.  
  845.          Function    Sets the FIFO trigger level (INS16550 only).
  846.  
  847.            Syntax    int SioFIFO(Port,LevelCode)
  848.                      int Port;       /* Port selected (COM1 thru COM4) */
  849.                      int LevelCode;  /* FIFO level code (see below) */
  850.  
  851.           Remarks    The SioFIFO function is used  to set the trigger level
  852.                      at which interrupts are generated. For example, if the
  853.                      FIFO level is set to 8, then the  INS16550  UART  will
  854.                      not  generate  an  interrupt  until  8 bytes have been
  855.                      received.   This  reduces  the  number  of  interrupts
  856.                      generated  and  allows  faster  processing with slower
  857.                      machines or when running simultaneous  ports.
  858.  
  859.                      In order to test if your  port  is  a  INS16550,  call
  860.                      SioFIFO with a LevelCode of other than FIFO_OFF.
  861.  
  862.                      SioFIFO  can  be  called for the INS8250/16450 without
  863.                      ill effect.
  864.  
  865.                      Code  PCL4C.H Name  Trigger Level
  866.                      -1      FIFO_OFF     Disable FIFO
  867.                       0      LEVEL_1      1 byte
  868.                       1      LEVEL_4      4 bytes
  869.                       2      LEVEL_8      8 bytes
  870.                       3      LEVEL_14     14 bytes
  871.  
  872.           Returns    -2 : Port not enabled. Call SioReset first.
  873.                      -4 : Port out of range.  Expected  0 to 3.
  874.                      >0 : FIFO level set.
  875.                       0 : FIFO level not set (not INS16550).
  876.  
  877.           Example    /* Set FIFO level to 8 */
  878.                      if( SioFIFO(Port,LEVEL_8) ) printf("FIFO reset\n");
  879.                      else printf("UART in not INS16550\n");
  880.  
  881.  
  882.  
  883.  
  884.  
  885.  
  886.  
  887.  
  888.  
  889.  
  890.  
  891.  
  892.  
  893.  
  894.  
  895.  
  896.  
  897.  
  898.  
  899.  
  900.         PCL4C Reference Manual                                 Page 15
  901.                                   SioFlow
  902.  
  903.  
  904.  
  905.          Function    Sets hardware (RTS/CTS) flow control.
  906.  
  907.            Syntax    int SioFlow(Port,Tics)
  908.                      int Port;       /* Port selected (COM1 thru COM4) */
  909.                      int Tics;       /* SioPutc timeout tics */
  910.  
  911.           Remarks    The SioFlow function is used  to  enable  or  disable
  912.                      hardware flow control. Hardware flow control uses  RTS
  913.                      and CTS to control data flow between the modem and the
  914.                      computer.  Refer to the User's Manual for a discussion
  915.                      of  flow  control.   To  enable hardware flow control,
  916.                      call SioFlow with Tics > 0.
  917.  
  918.                      "Tics"  is  the  number  of timer tics (18 per second)
  919.                      before a call to SioPutc will  time  out  because  the
  920.                      modem dropped CTS.
  921.  
  922.                      In order for hardware flow control to work  correctly,
  923.                      your  modem  must  also  be  configured  to  work with
  924.                      hardware flow control,  and  your  computer  to  modem
  925.                      cable must have RTS and CTS wired straight through. If
  926.                      you  enable  hardware  flow control, do not modify the
  927.                      RTS line (by calling SioRTS) unless you  know  exactly
  928.                      what you are doing.
  929.  
  930.                      Flow control is disabled after resetting  a  port.  To
  931.                      explicitly disable hardware flow control, call SioFlow
  932.                      with Tics = -1.
  933.  
  934.           Returns    -2 : Port not enabled. Call SioReset first.
  935.                      -4 : Port out of range.  Expected  0 to 3.
  936.                      =0 : Flow control disabled.
  937.                      >0 : Flow control enabled.
  938.  
  939.           Example    /* Enable flow control on COM1 */
  940.                      Code = SioFlow(COM1,18);
  941.                      if(Code>0) printf("Flow Control enabled\n");
  942.                      else SioError(Code);
  943.  
  944.                      /* disable flow control on COM2 */
  945.                      Code = SioFlow(COM2,-1);
  946.                      if(Code==0) printf("Flow Control disabled\n");
  947.                      else SioError(Code);
  948.  
  949.          See Also    SioPutc
  950.  
  951.  
  952.  
  953.  
  954.  
  955.  
  956.  
  957.  
  958.  
  959.  
  960.         PCL4C Reference Manual                                 Page 16
  961.                                   SioGetc
  962.  
  963.  
  964.  
  965.          Function    Reads the next character from the serial line.
  966.  
  967.            Syntax    int SioGetc(Port,Tics)
  968.                      int Port;     /* COM1 to COM4 */
  969.                      int Tics;     /* # timer tics */
  970.  
  971.           Remarks     The  SioGetc  function reads a byte from the selected
  972.                      serial port. The function will wait for the number  of
  973.                      system  tics  given  by  the  'Tics'  argument  before
  974.                      returning 'timed  out'.  There  are  18  tics  to  the
  975.                      second.
  976.  
  977.                      To specify no waiting, call SioGetc with Tics = 0.
  978.  
  979.           Returns    -2 : Port not enabled. Call SioReset first.
  980.                      -4 : Port out of range. Expecting  0 to 3.
  981.                      -1 : If timed out.
  982.                      >0 : Character read.
  983.  
  984.           Example    int c; /* MUST be 'int', not 'char' !!! */
  985.                      ...
  986.                      /* wait 9 tics for incoming character & display it */
  987.                      if( (c=SioGetc(COM1,9)) != -1)
  988.                      printf("Character is '%c'\n", c);
  989.                      else puts("Timed out");
  990.  
  991.          See Also    SioUnGetc and SioPutc.
  992.  
  993.  
  994.  
  995.  
  996.  
  997.  
  998.  
  999.  
  1000.  
  1001.  
  1002.  
  1003.  
  1004.  
  1005.  
  1006.  
  1007.  
  1008.  
  1009.  
  1010.  
  1011.  
  1012.  
  1013.  
  1014.  
  1015.  
  1016.  
  1017.  
  1018.  
  1019.  
  1020.         PCL4C Reference Manual                                 Page 17
  1021.                                   SioKeyPress
  1022.  
  1023.  
  1024.  
  1025.          Function    Detects if keyboard has been pressed.
  1026.  
  1027.            Syntax    int SioKeyPress()
  1028.  
  1029.           Remarks    The SioKeyPress function uses the  BIOS  to  test  the
  1030.                      keyboard   for   a   key   press   (including  control
  1031.                      characters).
  1032.  
  1033.                      SioKeyPress  calls  the  BIOS  directly  without   any
  1034.                      intermediate  buffering  or processing.  It is usually
  1035.                      faster than using the C library.
  1036.  
  1037.           Returns    zero
  1038.  
  1039.           Example    if( SioKeyPress() )
  1040.                        {c = SioKeyRead();
  1041.                         /* echo character c */
  1042.                         SioCrtWrite(c)
  1043.                        }
  1044.  
  1045.          See Also    SioCrtWrite and SioKeyRead.
  1046.  
  1047.  
  1048.  
  1049.  
  1050.  
  1051.  
  1052.  
  1053.  
  1054.  
  1055.  
  1056.  
  1057.  
  1058.  
  1059.  
  1060.  
  1061.  
  1062.  
  1063.  
  1064.  
  1065.  
  1066.  
  1067.  
  1068.  
  1069.  
  1070.  
  1071.  
  1072.  
  1073.  
  1074.  
  1075.  
  1076.  
  1077.  
  1078.  
  1079.  
  1080.         PCL4C Reference Manual                                 Page 18
  1081.                                   SioKeyRead
  1082.  
  1083.  
  1084.  
  1085.          Function    Reads the keyboard.
  1086.  
  1087.            Syntax    int SioKeyRead()
  1088.  
  1089.           Remarks    The SioKeyRead function  uses the  BIOS  to  read  the
  1090.                      keyboard.  It will wait until a character is typed.
  1091.  
  1092.                      SioKeyRead   calls   the  BIOS  directly  without  any
  1093.                      intermediate buffering or processing.  It  is  usually
  1094.                      faster than using the C library.
  1095.  
  1096.           Returns    Character typed (including control codes).
  1097.  
  1098.           Example    if(SioKeyPress())
  1099.                        {/* fetch the character */
  1100.                         c = SioKeyRead();
  1101.                         /* echo to screen */
  1102.                         SioCrtWrite(c);
  1103.                        }
  1104.  
  1105.          See Also    SioCrtWrite and SioKeyRead.
  1106.  
  1107.  
  1108.  
  1109.  
  1110.  
  1111.  
  1112.  
  1113.  
  1114.  
  1115.  
  1116.  
  1117.  
  1118.  
  1119.  
  1120.  
  1121.  
  1122.  
  1123.  
  1124.  
  1125.  
  1126.  
  1127.  
  1128.  
  1129.  
  1130.  
  1131.  
  1132.  
  1133.  
  1134.  
  1135.  
  1136.  
  1137.  
  1138.  
  1139.  
  1140.         PCL4C Reference Manual                                 Page 19
  1141.                                   SioInfo
  1142.  
  1143.  
  1144.  
  1145.          Function    Returns PCL4C library information.
  1146.  
  1147.            Syntax    int SioInfo(Cmd)
  1148.                      char Cmd;   /* Command (VERSION or MODEL) */
  1149.  
  1150.           Remarks    The  SioInfo  function  returns   an   integer   code
  1151.                      corresponding  to either the library version number or
  1152.                      the memory model that the library was assembled under.
  1153.  
  1154.                      SioInfo is provided so that you can verify the library
  1155.                      version number and memory model that a  PCL4C  library
  1156.                      was assembled under.
  1157.  
  1158.           Returns    VERSION ('V')
  1159.  
  1160.                      hex byte XY where version is denoted as X.Y
  1161.  
  1162.                      M_MODEL ('M')
  1163.  
  1164.                      0      Small
  1165.                      1      Compact
  1166.                      2      Medium
  1167.                      3      Large
  1168.  
  1169.           Example    char *Model[] = {"Small","Compact","Medium","Large"};
  1170.                      char Version;
  1171.                      char Model;
  1172.                      ...
  1173.                      /* display library version */
  1174.                      Version = SioInfo(VERSION);
  1175.                      printf("Library version is %d.%d\n",
  1176.                        Version/16, Version%16);
  1177.                      /* display memory model */
  1178.                      Model = SioInfo(MODEL);
  1179.                      printf("Memory Model is %s\n", Model[Code]);
  1180.  
  1181.  
  1182.  
  1183.  
  1184.  
  1185.  
  1186.  
  1187.  
  1188.  
  1189.  
  1190.  
  1191.  
  1192.  
  1193.  
  1194.  
  1195.  
  1196.  
  1197.  
  1198.  
  1199.  
  1200.         PCL4C Reference Manual                                 Page 20
  1201.                                   SioIRQ
  1202.  
  1203.  
  1204.  
  1205.          Function    Assigns an IRQ line and service routine to a port.
  1206.  
  1207.            Syntax    int SioIRQ(Port,IRQcode,ISRcode)
  1208.                      int Port;     /* Port selected (COM1 thru COM4) */
  1209.                      int IRQcode;  /* IRQ number [IRQ2..IRQ5] */
  1210.                      int ISRcode;  /* Interrupt service # [0,1,2,3] */
  1211.  
  1212.           Remarks    The  SioIRQ  function  assigns an IRQ line and
  1213.                      an  interrupt  service routine to a port. SioIRQ (like
  1214.                      SioUART) must be called  before  calling  SioReset  in
  1215.                      order   to   have  any  effect.
  1216.  
  1217.                      Unless   you   have   a   non-standard   serial   port
  1218.                      configuration  (or don't want to run more than 2 ports
  1219.                      concurrently), you will not need to call  SioIRQ.   Be
  1220.                      EXTREMELY  carefull  with  SioIRQ  as it can lock your
  1221.                      machine up if given incorrect information.
  1222.  
  1223.                      In  particular,  remember that your port hardware must
  1224.                      generate the interrupt that you have specified.   Also
  1225.                      be carefull about conflicting interrupt assignments.
  1226.  
  1227.                      IRQ  4 is the standard primary IRQ line while IRQ 3 is
  1228.                      the standard secondary  IRQ  line.   The  default  IRQ
  1229.                      codes are thus:
  1230.  
  1231.                      Port    IRQ    ISR
  1232.                      COM1    IRQ4   FirstISR
  1233.                      COM2    IRQ3   SecondISR
  1234.                      COM3    IRQ4   ThirdISR
  1235.                      COM4    IRQ3   FourthISR
  1236.  
  1237.                      The  IBM  PS/2  uses  non-standard  COM3 and COM4 port
  1238.                      configurations as follows:
  1239.  
  1240.                      Port    IRQ    UART
  1241.                      COM3    IRQ3   0x3220
  1242.                      COM4    IRQ3   0x3228
  1243.  
  1244.           Returns    -4 : Port out of range. Expecting 0 to 3.
  1245.                     -15 : Port already enabled.  SioReset has already been
  1246.                           called.
  1247.                       0 : Otherwise
  1248.  
  1249.           Example    /* use IRQ5 for COM3 */
  1250.                      SioUART(COM3,0x3220);
  1251.                      SioIRQ(COM3,IRQ5,ThirdISR);
  1252.                      /* we can now run 3 ports simultaneously */
  1253.  
  1254.          See Also    SioUART.
  1255.  
  1256.  
  1257.  
  1258.  
  1259.  
  1260.         PCL4C Reference Manual                                 Page 21
  1261.                                   SioLine
  1262.  
  1263.  
  1264.  
  1265.          Function    Reads the line status register.
  1266.  
  1267.            Syntax    int SioLine(Port)
  1268.                      int Port;     /* Port selected (COM1 thru COM4) */
  1269.  
  1270.           Remarks    The  SioLine function reads the line status  register.
  1271.                      The individual bit masks are as follows:
  1272.  
  1273.                      0x20  = Transmitter Buffer Empty.
  1274.                      0x10  = Break detected.
  1275.                      0x08  = Framming error.
  1276.                      0x04  = Parity error.
  1277.                      0x02  = Overrun error.
  1278.                      0x01  = Data ready.
  1279.  
  1280.                      The above are documented in the file PCL4C.H.
  1281.  
  1282.           Returns    -2 : Port not enabled. Call SioReset first.
  1283.                      -4 : Port out of range. Expecting  0 to 3.
  1284.                      >0 : Line status (rightmost byte of word).
  1285.  
  1286.           Example    int rc;
  1287.                      ...
  1288.                      rc = LineStatus(Port);
  1289.                      if(rc & (FramingError|ParityError|OverrunError))
  1290.                        {if(rc & FramingError) puts("Framing Error");
  1291.                         if(rc & ParityError)  puts("Parity Error");
  1292.                         if(rc & OverrunError) puts("Overrun Error");
  1293.                        }
  1294.                      else puts("No error");
  1295.  
  1296.          See Also    SioModem.
  1297.  
  1298.  
  1299.  
  1300.  
  1301.  
  1302.  
  1303.  
  1304.  
  1305.  
  1306.  
  1307.  
  1308.  
  1309.  
  1310.  
  1311.  
  1312.  
  1313.  
  1314.  
  1315.  
  1316.  
  1317.  
  1318.  
  1319.  
  1320.         PCL4C Reference Manual                                 Page 22
  1321.                                   SioLoopBack
  1322.  
  1323.  
  1324.  
  1325.          Function    Does a UART loopback test.
  1326.  
  1327.            Syntax    int SioLoopBack(Port)
  1328.                      int Port;     /* Port selected (COM1 thru COM4) */
  1329.  
  1330.           Remarks    SioLoopBack makes use of the built  in  loopback  test
  1331.                      capability  of the INS8250 UART.  Normally SioLoopBack
  1332.                      will never need to be called  except  if  you  suspect
  1333.                      that your UART is bad. See the LOOPBACK.C program.
  1334.  
  1335.  
  1336.           Returns      0 : Loopback test is successfull.
  1337.                       -2 : Port not enabled. Call SioReset first.
  1338.                       -4 : Port out of range.  Expecting   0  to 3.
  1339.                      -12 : Loopback test fails.
  1340.  
  1341.  
  1342.           Example    /* test port */
  1343.                      if(SioLoopBack(Port))
  1344.                      puts("Loopback test has failed");
  1345.                      else puts("Loopback test has succeeded");
  1346.  
  1347.  
  1348.  
  1349.  
  1350.  
  1351.  
  1352.  
  1353.  
  1354.  
  1355.  
  1356.  
  1357.  
  1358.  
  1359.  
  1360.  
  1361.  
  1362.  
  1363.  
  1364.  
  1365.  
  1366.  
  1367.  
  1368.  
  1369.  
  1370.  
  1371.  
  1372.  
  1373.  
  1374.  
  1375.  
  1376.  
  1377.  
  1378.  
  1379.  
  1380.         PCL4C Reference Manual                                 Page 23
  1381.                                   SioModem
  1382.  
  1383.  
  1384.  
  1385.          Function    Reads the modem status register.
  1386.  
  1387.            Syntax    int SioModem(Port, Mask)
  1388.                      int Port;    /* Port selected (COM1 thru COM4) */
  1389.                      char Mask;   /* Modem function mask */
  1390.  
  1391.           Remarks    The SioModem function reads the modem  register.   The
  1392.                      bit definitions for the function mask are as follows:
  1393.  
  1394.                       Bit    PCL4C.H Name   Function
  1395.                        7      DCD           Data Carrier Detect
  1396.                        6      RI            Ring Indicator
  1397.                        5      DSR           Data Set Ready
  1398.                        4      CTS           Clear To Send
  1399.                        3      DeltaDCD      Delta DCD   (DCD has changed)
  1400.                        2      DeltaRI       Delta RI    (RI has changed)
  1401.                        1      DeltaDSR      Delta DSR   (DSR has changed)
  1402.                        0      DeltaCTS      Delta CTS   (CTS has changed)
  1403.  
  1404.                      Bits 4 through 7 represent the absolute state of their
  1405.                      respective RS-232 inputs.  Bits 0 through 3 repesent a
  1406.                      change  in the state of their respective RS-232 inputs
  1407.                      since last read.
  1408.  
  1409.                      The above definitions are also in the PCL4C.H file for
  1410.                      use by your application program.
  1411.  
  1412.           Returns    -2 : Port not enabled. Call SioReset first.
  1413.                      -4 : Port out of range. Expecting  0 to 3.
  1414.                      >0 : Modem status (rightmost byte of word).
  1415.  
  1416.           Example    /* any change in DCD or CTS ? */
  1417.                      if(delta=SioModem(Port,DeltaDCD|DeltaCTS))
  1418.                        {status = SioModem(Port,DCD|CTS);
  1419.                         if(delta&DeltaDCD)
  1420.                           {if(status&DCD) c='T';
  1421.                            else c='F';
  1422.                           }
  1423.                         printf("DCD=%c\n",c);
  1424.                        }
  1425.                      if(delta&DeltaCTS)
  1426.                        {if(status&CTS)
  1427.                           {c='T'; else c='F';
  1428.                            printf("CTS=%c\n",c);
  1429.                           }
  1430.                        }
  1431.  
  1432.          See Also    SioCTS, SioDCD, SioDSR and SioRI.
  1433.  
  1434.  
  1435.  
  1436.  
  1437.  
  1438.  
  1439.  
  1440.         PCL4C Reference Manual                                 Page 24
  1441.                                   SioParms
  1442.  
  1443.  
  1444.  
  1445.          Function    Sets parity, stop bits, and word length.
  1446.  
  1447.            Syntax    int SioParms(Port,ParityCode,StopBitsCode,WordLengthCode)
  1448.                      int Port;           /* Port selected (COM1 thru COM4) */
  1449.                      int ParityCode;      /* parity code [0,1,2] */
  1450.                      int StopBitsCode;    /* stop bits code  [0,1] */
  1451.                      int WordLengthCode;  /* word length code [0,1,2,3] */
  1452.  
  1453.           Remarks    The SioParms function sets the parity, stop bits,  and
  1454.                      word length.  If the default parity (none), stop  bits
  1455.                      (1),  or  word length (8) is not acceptable, then they
  1456.                      can be changed by calling SioParms.  SioParms  can  be
  1457.                      called  either  before  or after calling SioReset. See
  1458.                      file PCL4C.H.
  1459.  
  1460.                                     Value   Description    PCL4C.H Name
  1461.                      ParityCode:    *0      no parity      NoParity
  1462.                                      1      odd parity     OddParity
  1463.                                      3      even parity    EvenParity
  1464.  
  1465.                      StopBitsCode:  *0      1 stop bit     OneStopBit
  1466.                                      1      2 stop bits    TwoStopBits
  1467.  
  1468.                      WordLengthCode: 0      5 data bits    WordLength5
  1469.                                      1      6 data bits    WordLength6
  1470.                                      2      7 data bits    WordLength7
  1471.                                     *3      8 data bits    WordLength8
  1472.  
  1473.                      * = Default
  1474.  
  1475.           Returns    -4 : Port out of range. Expecting 0 to 3.
  1476.                      -7 : Bad parity code selected. Expecting  0 to 2.
  1477.                      -8 : Bad stop bits code. Expecting  0 or 1.
  1478.                      -9 : Bad word length code. Expecting  0 to 3.
  1479.  
  1480.           Example    /* set no parity, 1 stop bit, and 8 bit data for COM1 */
  1481.                      SioParms(COM1,NoParity,OneStopBit,WordLength8);
  1482.  
  1483.          See Also    SioReset.
  1484.  
  1485.  
  1486.  
  1487.  
  1488.  
  1489.  
  1490.  
  1491.  
  1492.  
  1493.  
  1494.  
  1495.  
  1496.  
  1497.  
  1498.  
  1499.  
  1500.         PCL4C Reference Manual                                 Page 25
  1501.                                  SioPutc
  1502.  
  1503.  
  1504.  
  1505.          Function    Transmit a character over a serial line.
  1506.  
  1507.            Syntax    int SioPutc(Port,c)
  1508.                      int Port;     /* Port selected (COM1 thru COM4) */
  1509.                      char c;       /* character to send */
  1510.  
  1511.           Remarks    The SioPutc function transmits one character over  the
  1512.                      selected serial line.
  1513.  
  1514.                      If  flow  control  has  been enabled, then SioPutc may
  1515.                      return a -1 (time out) if the number of tics specified
  1516.                      in the SioFlow function was exceeded waiting  for  the
  1517.                      modem  to raise CTS.  Refer to the User's Manual for a
  1518.                      discussion of flow control.
  1519.  
  1520.           Returns    -2 : Port not enabled. Call SioReset first.
  1521.                      -4 : Port out of range. Expecting  0 to 3.
  1522.                      -1 : Timed out waiting for CTS (flow control enabled)
  1523.  
  1524.           Example    char crc;
  1525.                      char buffer[128];
  1526.                      ...
  1527.                      /* transmit 128 byte buffer + CRC */
  1528.                      crc = 0;
  1529.                      for(i=0;i<128;i++)
  1530.                        {crc = crcupdate( buffer[i], crc);
  1531.                         SioPutc(Port, buffer[i]);
  1532.                        }
  1533.                      SioPutc(crc);
  1534.  
  1535.          See Also    SioGetc and SioFlow.
  1536.  
  1537.  
  1538.  
  1539.  
  1540.  
  1541.  
  1542.  
  1543.  
  1544.  
  1545.  
  1546.  
  1547.  
  1548.  
  1549.  
  1550.  
  1551.  
  1552.  
  1553.  
  1554.  
  1555.  
  1556.  
  1557.  
  1558.  
  1559.  
  1560.         PCL4C Reference Manual                                 Page 26
  1561.                                   SioRead
  1562.  
  1563.  
  1564.  
  1565.          Function    Reads any UART register.
  1566.  
  1567.            Syntax    int SioRead(Port)
  1568.                      int Port;     /* Port selected (COM1 thru COM4) */
  1569.  
  1570.           Remarks    The  SioReset  function directly reads the contents of
  1571.                      any of the 7 UART registers. This function  is  useful
  1572.                      when  debugging  application programs, and as a method
  1573.                      for verifying UART contents. Refer to  the  PCL  Users
  1574.                      Manual for a discussion of the 7 UART registers.
  1575.  
  1576.          Returns      -3 : No buffer available. Call SioRxBuf first.
  1577.                       -4 : Port out of range. Expecting  0 to 3.
  1578.  
  1579.           Example    int Reg;  /* UART register */
  1580.                      int Contents; /* contents of UART */
  1581.                      /* print contents of 7 UART registers */
  1582.                      for(Reg=0;Reg<7;Reg++)
  1583.                         {Contents = SioRead(Port,Reg);
  1584.                          printf("COM%d:  UART Register %d = %d\n",
  1585.                            1+Port,Reg,Contents);
  1586.                         }
  1587.  
  1588.  
  1589.  
  1590.  
  1591.  
  1592.  
  1593.  
  1594.  
  1595.  
  1596.  
  1597.  
  1598.  
  1599.  
  1600.  
  1601.  
  1602.  
  1603.  
  1604.  
  1605.  
  1606.  
  1607.  
  1608.  
  1609.  
  1610.  
  1611.  
  1612.  
  1613.  
  1614.  
  1615.  
  1616.  
  1617.  
  1618.  
  1619.  
  1620.         PCL4C Reference Manual                                 Page 27
  1621.                                   SioReset
  1622.  
  1623.  
  1624.  
  1625.          Function    Initialize a serial port for processing.
  1626.  
  1627.            Syntax    int SioReset(Port,BaudCode)
  1628.                      int Port;     /* Port selected (COM1 thru COM4) */
  1629.                      int BaudCode; /* baud code or -1 */
  1630.  
  1631.           Remarks    The SioReset function initializes the selected  serial
  1632.                      port.  SioReset should be called after calling SioParm
  1633.                      and  SioRxBuf  but  before  making  any other calls to
  1634.                      PCL4C.  SioReset uses the parity, stop bits, and  word
  1635.                      length  value  previously  set  if SioParm was called,
  1636.                      otherwise the default values (see SioParm) are used.
  1637.  
  1638.                      Recall that COM1 and COM3  share  the  same  interrupt
  1639.                      vector  and  therefore  cannot operate simultaneously.
  1640.                      Similiarly,   COM2    and    COM4    cannot    operate
  1641.                      simultaneously. Any other combination of two ports can
  1642.                      be used.
  1643.  
  1644.                      By specifing NORESET (-1) for the baud rate code,  the
  1645.                      port will NOT be reset.  This is used to "take over" a
  1646.                      port  from a host communications program that allows a
  1647.                      "DOS gateway".  External protocols can be  implemented
  1648.                      this  way.   See  SioBaud  for a list of the baud rate
  1649.                      codes, or see "PCL4C.H".
  1650.  
  1651.          Returns      -3 : No buffer available. Call SioRxBuf first.
  1652.                       -4 : Port out of range. Expecting  0 to 3.
  1653.                      -11 : Bad baud rate code selected. Expecting  0 to 9.
  1654.                      -13 : UART  undefined.   SioUART(Port,0)  was  called
  1655.                            previously.
  1656.                      -14 : Bad or missing UART.  You may not have hardware
  1657.                            present.
  1658.                      -15 : Port already enabled.  SioReset has already been
  1659.                            called.
  1660.                      -16 : Interrupt already in use.
  1661.  
  1662.           Example    char Buffer[128];
  1663.                      int rc;
  1664.                      ...
  1665.                      SioRxBuf(COM1,Buffer,Size128);
  1666.                      rc = SioReset(Com1,Baud38400);
  1667.                      if(rc==0) puts("RESET ok");
  1668.                      else if(rc<0) SioError(rc);
  1669.                      else
  1670.                        {if(rc&OverrunError) puts("Overrun Error");
  1671.                         if(rc&ParityError) puts("Parity Error");
  1672.                         if(rc&FramingError) puts("Framing Error");
  1673.                         if(rc&BreakDetected) puts("Break Detected");
  1674.                        }
  1675.  
  1676.          See Also    SioBaud, SioParms, SioRxBuf, SioDone, and SioUART.
  1677.  
  1678.  
  1679.  
  1680.         PCL4C Reference Manual                                 Page 28
  1681.                                   SioRI
  1682.  
  1683.  
  1684.  
  1685.          Function    Reads the Ring Indicator (RI) modem status bit.
  1686.  
  1687.            Syntax    int SioRI(Port)
  1688.                      int Port;     /* Port selected (COM1 thru COM4) */
  1689.  
  1690.           Remarks    The SioRI function is used to read the Ring  Indicator
  1691.                      (RI) modem status bit. Also see SioModem.
  1692.  
  1693.           Returns    -2 : Port not enabled. Call SioReset first.
  1694.                      -4 : Port out of range.  Expecting   0  to 3.
  1695.                       0 : RI is clear.
  1696.                      >0 : RI is set (RING has occurred).
  1697.  
  1698.           Example    /* check for Ring */
  1699.                      if(SioRI(Port))
  1700.                        {puts("RING ");
  1701.                         /* process RING */
  1702.                         ...
  1703.                        }
  1704.  
  1705.          See Also    SioDSR, SioCTS, SioDCD, and SioModem.
  1706.  
  1707.  
  1708.  
  1709.  
  1710.  
  1711.  
  1712.  
  1713.  
  1714.  
  1715.  
  1716.  
  1717.  
  1718.  
  1719.  
  1720.  
  1721.  
  1722.  
  1723.  
  1724.  
  1725.  
  1726.  
  1727.  
  1728.  
  1729.  
  1730.  
  1731.  
  1732.  
  1733.  
  1734.  
  1735.  
  1736.  
  1737.  
  1738.  
  1739.  
  1740.         PCL4C Reference Manual                                 Page 29
  1741.                                   SioRTS
  1742.  
  1743.  
  1744.  
  1745.          Function    Sets, clears, or reads the Request to Send (RTS) line.
  1746.  
  1747.            Syntax    int SioRTS(Port,Cmd)
  1748.                      int Port;     /* COM1 to COM4 */
  1749.                      char Cmd;     /* RTS command (SET, CLEAR, or READ) */
  1750.  
  1751.           Remarks    The SioRTS function controls the Request to Send  (RTS
  1752.                      bit  in  the  modem control register.
  1753.  
  1754.                      The  RTS  line is used by some error correcting modems
  1755.                      to implement hardware flow control.  RTS is dropped by
  1756.                      the computer to signal the modem not to send data, and
  1757.                      is raised to signal the modem to continue.
  1758.  
  1759.                      Refer to the User's Manual for a  discussion  of  flow
  1760.                      control.
  1761.  
  1762.                      Commands  (defined in PCL4C.H) are:
  1763.  
  1764.                      SET_LINE ('S')   -- set RTS (ON)
  1765.                      CLEAR_LINE ('C') -- clear RTS (OFF)
  1766.                      READ_LINE ('R')  -- read RTS
  1767.  
  1768.           Returns    -2 : Port not enabled. Call SioReset first.
  1769.                      -4 : Port out of range. Expecting  0 to 3.
  1770.                      -5 : Command is not one of 'S', 'C', or 'R'.
  1771.                       0 : RTS is OFF (READ_LINE Command).
  1772.                      >0 : RTS is ON  (READ_LINE Command).
  1773.  
  1774.           Example    /* turn off RTS for modem */
  1775.                      SioRTS(Port,CLEAR);
  1776.  
  1777.          See Also    SioFlow and SioDTR.
  1778.  
  1779.  
  1780.  
  1781.  
  1782.  
  1783.  
  1784.  
  1785.  
  1786.  
  1787.  
  1788.  
  1789.  
  1790.  
  1791.  
  1792.  
  1793.  
  1794.  
  1795.  
  1796.  
  1797.  
  1798.  
  1799.  
  1800.         PCL4C Reference Manual                                 Page 30
  1801.                                   SioRxBuf
  1802.  
  1803.  
  1804.  
  1805.          Function    Sets up receive buffers.
  1806.  
  1807.            Syntax    int SioRxBuf(Port,Buffer,SizeCode)
  1808.                      int Port;     /* Port selected (COM1 thru COM4) */
  1809.                      char *Buffer  /* Receive buffer */
  1810.                      int SizeCode; /* Buffer size code */
  1811.  
  1812.           Remarks    The SioRxBuf function passes the address and  size  of
  1813.                      the  receive  buffer  to  PCL4C.   Recall  that  PCL4C
  1814.                      requires  a  receive   buffer   for   each   port   in
  1815.                      simultaneous  operation  since the receive function is
  1816.                      interrupt driven.  SioRxBuf passes the receive  buffer
  1817.                      to   PCL4C   for  both  the  primary  (COM1/COM3)  and
  1818.                      secondary (COM2/COM4) ports.  It must be called before
  1819.                      any incoming characters can be received. SioRxBuf must
  1820.                      be called before  SioReset.   Buffer  size  codes  are
  1821.                      listed in "PCL4C.H".
  1822.  
  1823.                      Size Code       Buffer Size    PCL4C.H Name
  1824.                         0              8 bytes        Size8
  1825.                         1             16 bytes        Size16
  1826.                         2             32 bytes        Size32
  1827.                         3             64 bytes        Size64
  1828.                         4            128 bytes        Size128
  1829.                         5            256 bytes        Size256
  1830.                         6            512 bytes        Size512
  1831.                         7           1024 bytes        Size1024 or Size1K
  1832.                         8           2048 bytes        Size2048 or Size2K
  1833.                         9           4096 bytes        Size4096 or Size4K
  1834.                        10           8192 bytes        Size8192 or Size8K
  1835.                        11          16384 bytes        Size16384 or Size16K
  1836.                        12          32768 bytes        Size32768 or Size32K
  1837.  
  1838.           Returns    -4 : Port out of range. Expecting 0 to 3.
  1839.                     -10 : Bad buffer size code. Expecting 0 to 11.
  1840.  
  1841.           Example    char RxBuf[1024]; /* declare as global */
  1842.                      ...
  1843.                      /* setup 1K receive buffer */
  1844.                      SioRxBuf(COM1, RxBuf, Size1024);
  1845.                      /* ready to call SioReset */
  1846.  
  1847.          See Also    SioReset.
  1848.  
  1849.  
  1850.  
  1851.  
  1852.  
  1853.  
  1854.  
  1855.  
  1856.  
  1857.  
  1858.  
  1859.  
  1860.         PCL4C Reference Manual                                 Page 31
  1861.                                   SioRxFlush
  1862.  
  1863.  
  1864.  
  1865.          Function    To  flush  the  receive  buffer  associated  with  the
  1866.                      specified port.
  1867.  
  1868.            Syntax    int SioRxFlush(Port)
  1869.                      int Port;   /* Port selected (COM1 thru COM4) */
  1870.  
  1871.           Remarks    The SioRxFlush function will delete any characters  in
  1872.                      the  receive  buffer  for  the  specified port.  After
  1873.                      execution, the receive buffer  will  be  empty.   Call
  1874.                      SioRxBuf after resetting a port in order to delete any
  1875.                      spurious characters.
  1876.  
  1877.           Returns    -2 : Port not enabled. Call SioReset first.
  1878.                      -4 : Port out of range. Expecting 0 to 3.
  1879.  
  1880.           Example    char buffer[1024];
  1881.                      ...
  1882.                      /* setup receive buffer & reset port */
  1883.                      SioRxBuf(COM1,buffer,Size1024);
  1884.                      SioReset(COM1,Baud115200);
  1885.                      /* flush any spurious character */
  1886.                      SioRxFlush(COM1);
  1887.                      /* ready for serial processing ! */
  1888.                      ...
  1889.  
  1890.          See Also    SioRxQue.
  1891.  
  1892.  
  1893.  
  1894.  
  1895.  
  1896.  
  1897.  
  1898.  
  1899.  
  1900.  
  1901.  
  1902.  
  1903.  
  1904.  
  1905.  
  1906.  
  1907.  
  1908.  
  1909.  
  1910.  
  1911.  
  1912.  
  1913.  
  1914.  
  1915.  
  1916.  
  1917.  
  1918.  
  1919.  
  1920.         PCL4C Reference Manual                                 Page 32
  1921.                                   SioRxQue
  1922.  
  1923.  
  1924.  
  1925.          Function    Returns the number of characters in the receive queue.
  1926.  
  1927.            Syntax    int SioRxQue(Port)
  1928.                      int Port;     /* Port selected (COM1 thru COM4) */
  1929.  
  1930.           Remarks    The  SioRxQue  function  will  return  the  number  of
  1931.                      characters  in  the  receive  queue at the time of the
  1932.                      call. It  can  be  used  to  implement  XON/XOFF  flow
  1933.                      control.
  1934.  
  1935.           Returns    -2 : Port not enabled. Call SioReset first.
  1936.                      -4 : Port out of range. Expecting  0 to 3.
  1937.  
  1938.           Example    #define XON 0x11
  1939.                      #define XOFF 0x13
  1940.                      int count;
  1941.                      char last = XON;
  1942.                      char Buffer[128];
  1943.                      ...
  1944.                      SioRxBuf(COM1,Buffer,Size128);
  1945.                      /* implement XON / XOFF */
  1946.                      count = SioRxQue(COM1);
  1947.                      if((last==XON)&&(count>120))
  1948.                        {SioPutc(COM1,XOFF);
  1949.                         last = XOFF;
  1950.                        }
  1951.                      if((last==XOFF)&&(count<8))
  1952.                        {SioPutc(COM1,XON);
  1953.                         last = XON;
  1954.                        }
  1955.  
  1956.         See Also     SioRxFlush.
  1957.  
  1958.  
  1959.  
  1960.  
  1961.  
  1962.  
  1963.  
  1964.  
  1965.  
  1966.  
  1967.  
  1968.  
  1969.  
  1970.  
  1971.  
  1972.  
  1973.  
  1974.  
  1975.  
  1976.  
  1977.  
  1978.  
  1979.  
  1980.         PCL4C Reference Manual                                 Page 33
  1981.                                   SioTimer
  1982.  
  1983.  
  1984.  
  1985.          Function    Returns the number of system clock tics since midnight.
  1986.  
  1987.            Syntax    long SioTimer()
  1988.  
  1989.           Remarks    The SioTimer function will return the number of system
  1990.                      clock tics since midnight, at 18.2065 tics per second.
  1991.                      This function is usefull for timing various functions.
  1992.                      Also see SioDelay.
  1993.  
  1994.           Returns    timer tics.
  1995.  
  1996.           Example    long time;
  1997.                      ...
  1998.                      time = SioTimer();
  1999.                      ...
  2000.                      printf("Elasped time = %ld tics\n",SioTimer() - time);
  2001.  
  2002.          See Also    SioDelay.
  2003.  
  2004.  
  2005.  
  2006.  
  2007.  
  2008.  
  2009.  
  2010.  
  2011.  
  2012.  
  2013.  
  2014.  
  2015.  
  2016.  
  2017.  
  2018.  
  2019.  
  2020.  
  2021.  
  2022.  
  2023.  
  2024.  
  2025.  
  2026.  
  2027.  
  2028.  
  2029.  
  2030.  
  2031.  
  2032.  
  2033.  
  2034.  
  2035.  
  2036.  
  2037.  
  2038.  
  2039.  
  2040.         PCL4C Reference Manual                                 Page 34
  2041.                                   SioUART
  2042.  
  2043.  
  2044.  
  2045.          Function    Sets the UART base address.
  2046.  
  2047.            Syntax    int SioUART(Port,Address)
  2048.                      int Port;     /* COM1 to COM4 */
  2049.                      int Address;  /* UART address */
  2050.  
  2051.           Remarks    The  SioUART  function sets  the UART base address for
  2052.                      the specified port.  SioUART  must  be  called  before
  2053.                      SioReset  in  order to have effect.  Be extremely sure
  2054.                      that you know what you are doing! Note that PCL4C uses
  2055.                      the  standard  PC/XT/AT  port   addresses,   interrupt
  2056.                      request   lines,   and   interrupt   service  vectors.
  2057.                      Therefore,  this   function   is   only   needed   for
  2058.                      non-standard ports.
  2059.  
  2060.           Returns    >0 : The previous base address for this port.
  2061.                      -4 : Port out of range.  Expecting 0 to 3.
  2062.                     -15 : Port already enabled.  SioReset has already been
  2063.                           called.
  2064.  
  2065.           Example    /* Record the fact that you don't have COM4 */
  2066.                      SioUART(COM4, 0);
  2067.  
  2068.          See Also    SioReset, SioIRQ.
  2069.  
  2070.  
  2071.  
  2072.  
  2073.  
  2074.  
  2075.  
  2076.  
  2077.  
  2078.  
  2079.  
  2080.  
  2081.  
  2082.  
  2083.  
  2084.  
  2085.  
  2086.  
  2087.  
  2088.  
  2089.  
  2090.  
  2091.  
  2092.  
  2093.  
  2094.  
  2095.  
  2096.  
  2097.  
  2098.  
  2099.  
  2100.         PCL4C Reference Manual                                 Page 35
  2101.                                   SioUnGetc
  2102.  
  2103.  
  2104.  
  2105.          Function    "Un-gets" the last character read with SioGetc().
  2106.  
  2107.            Syntax    int SioUnGetc(Port,c)
  2108.                      int Port;     /* Port selected (COM1 thru COM4) */
  2109.                      char c;       /* character to unget */
  2110.  
  2111.           Remarks      The   SioUnGetc   function  returns  ("pushes")  the
  2112.                      character back into  the  serial  input  buffer.   The
  2113.                      character  pushed  will be the next character returned
  2114.                      by SioGetc.  Only one character can  be  pushed  back.
  2115.                      This function works just like the "ungetc" function in
  2116.                      the C language.
  2117.  
  2118.           Returns    -2 : Port not enabled. Call SioReset first.
  2119.                      -4 : Port out of range. Expecting 0 to 3.
  2120.  
  2121.           Example    /* push back c so next SioGetc will get it */
  2122.                      SioUnGetc(Port,c);
  2123.  
  2124.          See Also    SioReset.
  2125.  
  2126.  
  2127.  
  2128.  
  2129.  
  2130.  
  2131.  
  2132.  
  2133.  
  2134.  
  2135.  
  2136.  
  2137.  
  2138.  
  2139.  
  2140.  
  2141.  
  2142.  
  2143.  
  2144.  
  2145.  
  2146.  
  2147.  
  2148.  
  2149.  
  2150.  
  2151.  
  2152.  
  2153.  
  2154.  
  2155.  
  2156.  
  2157.  
  2158.  
  2159.  
  2160.         PCL4C Reference Manual                                 Page 36
  2161.                                   Function Sumary
  2162.  
  2163.  
  2164.  
  2165.          ***********************************************************
  2166.          * Function    *   Arg1   *   Arg2   *   Arg3   *   Arg4   *
  2167.          ***********************************************************
  2168.          * SioBaud     * Port     * BaudCode *          *          *
  2169.          * SioBrkKey   *          *          *          *          *
  2170.          * SioBrkSig   * Port     * Cmd      *          *          *
  2171.          * SioCrtWrite * Ch       *          *          *          *
  2172.          * SioCTS      * Port     *          *          *          *
  2173.          * SioDCD      * Port     *          *          *          *
  2174.          * SioDelay    * Tics     *          *          *          *
  2175.          * SioDone     * Port     *          *          *          *
  2176.          * SioDSR      * Port     *          *          *          *
  2177.          * SioDTR      * Port     * Cmd      *          *          *
  2178.          * SioError    * Code     *          *          *          *
  2179.          * SioFIFO     * Port     * FIFOcode *          *          *
  2180.          * SioFlow     * Port     * Tics     *          *          *
  2181.          * SioGetc     * Port     * Tics     *          *          *
  2182.          * SioKeyPress *          *          *          *          *
  2183.          * SioKeyRead  *          *          *          *          *
  2184.          * SioInfo     * Cmd      *          *          *          *
  2185.          * SioIRQ      * Port     * IRQcode  * ISRcode  *          *
  2186.          * SioLine     * Port     *          *          *          *
  2187.          * SioLoopBack * Port     *          *          *          *
  2188.          * SioModem    * Port     * Mask     *          *          *
  2189.          * SioParms    * Port     * Parity   * StopBits *WordLength*
  2190.          * SioPutc     * Port     * Ch       *          *          *
  2191.          * SioRead     * Port     * Register *          *          *
  2192.          * SioReset    * Port     * BaudCode *          *          *
  2193.          * SioRI       * Port     *          *          *          *
  2194.          * SioRTS      * Port     * Cmd      *          *          *
  2195.          * SioRxBuf    * Port     * Buffer   * SizeCode *          *
  2196.          * SioRxFlush  * Port     *          *          *          *
  2197.          * SioRxQue    * Port     *          *          *          *
  2198.          * SioTimer    *          *          *          *          *
  2199.          * SioUART     * Port     * Address  *          *          *
  2200.          * SioUnGetc   * Port     * Ch       *          *          *
  2201.          ***********************************************************
  2202.  
  2203.          [ 33 functions ]
  2204.  
  2205.  
  2206.  
  2207.  
  2208.  
  2209.  
  2210.  
  2211.  
  2212.  
  2213.  
  2214.  
  2215.  
  2216.  
  2217.  
  2218.  
  2219.  
  2220.         PCL4C Reference Manual                                 Page 37
  2221.                              Error Code Summary
  2222.  
  2223.  
  2224.  
  2225.          *****************************************************************
  2226.          * Code *  Description                                           *
  2227.          *****************************************************************
  2228.          *   0  *  No error.                                             *
  2229.          *  -1  *  Timeout waiting for I/O.                              *
  2230.          *  -2  *  Port not enabled. Call SioReset first.                *
  2231.          *  -3  *  No buffer available. Call SioRxBuf first.             *
  2232.          *  -4  *  Port out of range. Expected 0 to 3. (COM1 = 0)        *
  2233.          *  -5  *  Expected 'S', 'C', or 'R' as 2nd argument.            *
  2234.          *  -6  *  Expected 'A', 'C', or 'D' as 2nd argument.            *
  2235.          *  -7  *  Bad parity code specified. Expected 0 to 7.           *
  2236.          *  -8  *  Bad stop bits code specified. Expected 0 or 1.        *
  2237.          *  -9  *  Bad wordlength code specified. Expected 0 to 3.       *
  2238.          * -10  *  Bad buffer size code specified. Expected 0 to 11.     *
  2239.          * -11  *  Bad baud rate code. Expected 0 to 9.                  *
  2240.          * -12  *  Loopback test fails.                                  *
  2241.          * -13  *  UART undefined.                                       *
  2242.          * -14  *  Missing or bad UART.                                  *
  2243.          * -15  *  Port already enabled.                                 *
  2244.          * -16  *  Interrupt already in use.                             *
  2245.          *****************************************************************
  2246.  
  2247.  
  2248.  
  2249.  
  2250.  
  2251.  
  2252.  
  2253.  
  2254.  
  2255.  
  2256.  
  2257.  
  2258.  
  2259.  
  2260.  
  2261.  
  2262.  
  2263.  
  2264.  
  2265.  
  2266.  
  2267.  
  2268.  
  2269.  
  2270.  
  2271.  
  2272.  
  2273.  
  2274.  
  2275.  
  2276.  
  2277.  
  2278.  
  2279.  
  2280.         PCL4C Reference Manual                                 Page 38
  2281.  
  2282.  
  2283.